package com.base.common.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.operamasks.faces.annotation.DefineConverter;

@DefineConverter(id = "emailFormatter")
public class EmailFormatter implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		if (value == null || "".equals(value.toString())) {
			return "";
		} else {
			String script = "mailto:" + value.toString();
			return "<a href=\"" + script + "\">" + value.toString() + "</a>";
		}
	}

}
